namespace CSharpPro._1013;

public class demo4
{
    static void main()
    {
        Console.WriteLine("1000 以内的完数有：");
        for (int number = 2; number < 1000; number++)
        {
            int properDivisorsSum = CalculateProperDivisorsSum(number);
            if (properDivisorsSum == number)
            {
                Console.WriteLine(number);
            }
        }
    }
    
    static int CalculateProperDivisorsSum(int num)
    {
        int sum = 0;
        for (int i = 1; i < num; i++)
        {
            if (num % i == 0)
            {
                sum += i;
            }
        }

        return sum;
    }
}
